-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain API changes #2403
base: main
Are you sure you want to change the base?
Explain API changes #2403
Conversation
93c1f96
to
8b52ed7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to have Unit test for each case
- Disk-based search with valid rescore context.
- Radial search.
- ANN search (default case).
- Shard-level rescoring enabled.
- Shard-level rescoring disabled.
- Filter weight case where filtered IDs are less than k.
- Filter threshold value greater than cardinality.
- Missing native engine files.
- Valid context with matching document and disk-based search.
And Please validate with Explaination Object.
@Vikasht34 yes the tests are not yet added in here, hence its in a draft status. I will add the coverage with all the possible cases. |
8b52ed7
to
bffbdac
Compare
Signed-off-by: Neetika Singhal <[email protected]>
bffbdac
to
7c4f425
Compare
@navneet1v / @Vikasht34 would you please review the changes? |
@neetikasinghal can you please add an entry in the change log |
yup i generally add it towards the end of the review so that its easier to rebase with the latest changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at high level in the code, need to go through more in terms of explanation. But one thing I want to add is I am not seeing any ITs related to explain api. Can we please add them too
@@ -46,6 +51,11 @@ public float scoreTranslation(float rawScore) { | |||
return 1 / (1 + rawScore); | |||
} | |||
|
|||
@Override | |||
public String explainScoreTranslation(float rawScore) { | |||
return "`1 / (1 + rawScore)`"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this as private static final string.
@@ -77,6 +87,11 @@ public float scoreTranslation(float rawScore) { | |||
return Math.max((2.0F - rawScore) / 2.0F, 0.0F); | |||
} | |||
|
|||
@Override | |||
public String explainScoreTranslation(float rawScore) { | |||
return "`Math.max((2.0F - rawScore) / 2.0F, 0.0F)`"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
if (score == 0) { | ||
score = knnScore; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be the first check we do when we enter the if condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, knnScore should be computed for it to be assigned to the score.
} | ||
|
||
private float getKnnScore(LeafReaderContext context, int doc) throws IOException { | ||
KNNScorer knnScorer = (KNNScorer) scorer(context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we are computing the scorer for every doc again and again? In case of explain should we just cache scorer in the KNNExplainObject once the first explain call happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a good point, will make changes
yup, that WIP as my setup for ITs was broken. I am able to fix that now, however the PR has the coverage for all the UTs. |
Signed-off-by: Neetika Singhal <[email protected]>
Description
Add support for explain for Exact/ANN/Radial/Disk/Filtering k-nn search. Score calculation explanation is currently added only for ANN search.
Proposal for explain is given here: #875 (comment)
ITs - WIP..
Related Issues
Resolves #875
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.